package com.simp.controller;

import com.simp.page.R;
import com.simp.page.SuperController;
import com.simp.service.CommonService;
import com.simp.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author pan.shun
 * @since 2022/3/17 20:46
 */
@Api(tags = "公共API")
@RestController
@RequestMapping("/common")
public class CommonController extends SuperController {

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private CommonService commonService;

    @ApiOperation(value = "给其他应用服务验证使用", notes = "给其他应用服务验证使用")
    @GetMapping("/check")
    public R check() {
        return success();
    }

    @ApiOperation(value = "通过用户名获取头像", notes = "通过用户名获取头像")
    @GetMapping("getUserHeadByUserName/{userName}")
    public R getUserHeadByUserName(@PathVariable String userName) {
        return sysUserService.getUserHeadByUserName(userName);
    }

    @ApiOperation(value = "查询最近启动时间")
    @GetMapping("/getEarlyStartTime")
    public R getEarlyStartTime() {
        return commonService.getEarlyStartTime();
    }

    @ApiOperation(value = "查询缓存信息")
    @GetMapping("/getAllCacheInfo")
    public R getAllCacheInfo() {
        return commonService.getAllCacheInfo();
    }

}
